﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.AlbLab.GEP.Dao.Base;
using Com.AlbLab.GEP.Dao.Interface;
using Com.AlbLab.GEP.Domain.Entities;
using Oracle.DataAccess.Client;
using Com.AlbLab.GEP.Domain;

namespace Com.AlbLab.GEP.Dao.Impl
{
    public class AnagUfficiDao : OracleDao<OracleSessionManager, ISessionModel>, IAnagUfficiDao
    {
        public AnagUfficiDao(OracleSessionManager daoContext)
            : base(daoContext)
        {
            if (!base.Context.Session_isActive())
            {
                base.Context.Session_Init();
                base.CurrentConnection.Open();
            }
        }
        private string seletctAll = "select * from GEP_UFFICI order by UFF_DESCRIZIONE asc";

        #region IDao<GEP_ANA_UFFICI,string> Members

        public Dictionary<string, GEP_ANA_UFFICI> GetAll()
        {
            throw new NotImplementedException();
        }

        public Dictionary<string, GEP_ANA_UFFICI> GetAllByTipo(int tipo)
        {
            Dictionary<string, GEP_ANA_UFFICI> list = null;
            GEP_ANA_UFFICI t;

            //try
            //{
            //list = new Dictionary<string, GEP_ANA_UFFICI>();
            //t = new GEP_ANA_UFFICI();
            //t.Id_cod_ufficio = "1";
            //t.Des_ufficio = "UFFICIO COMMERCIALE";

            //list.Add("1",t);
            //t = new GEP_ANA_UFFICI();
            //t.Id_cod_ufficio = "2";
            //t.Des_ufficio = "UFFICIO TECNICO";

            //list.Add("2",t);
            //}
            //catch (Exception e0x)
            //{
            //    throw new ManagedException("EX-MO001", e0x);
            //}
            Oracle.DataAccess.Client.OracleCommand cmd = new Oracle.DataAccess.Client.OracleCommand(seletctAll, CurrentConnection);
            try
            {
                using (OracleDataReader r = cmd.ExecuteReader())
                {
                    if (r.HasRows)
                    {
                        list = new Dictionary<string, GEP_ANA_UFFICI>();
                        while (r.Read())
                        {
                            t = DaoOracleDbHelper.MapUffici(r);
                            list.Add(t.Id_cod_ufficio, t);
                        }
                    }
                }
            }
            catch (Exception e0x)
            {
                throw new ManagedException("EX-MO001", e0x);
            }
            return list;
        }

        public Com.AlbLab.GEP.Domain.Entities.GEP_ANA_UFFICI GetById(string id)
        {
            throw new NotImplementedException();
        }

        public void Insert(Com.AlbLab.GEP.Domain.Entities.GEP_ANA_UFFICI entity)
        {
            throw new NotImplementedException();
        }

        public void Update(Com.AlbLab.GEP.Domain.Entities.GEP_ANA_UFFICI entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(string id)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        #endregion


    }
}
